/**
 * 人才政策管理 人才政策录入
 */
<template>
    <div>
        <!-- 面包屑导航 -->
        <el-breadcrumb separator-class="el-icon-arrow-right">
            <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>人才政策录入</el-breadcrumb-item>
        </el-breadcrumb>
        <el-form ref="formData" :model="form" label-width="120px">
            <el-form-item label="人才政策标题">
                <el-input
                    v-model="form.title"
                    placeholder="请输入标题"
                ></el-input>
            </el-form-item>
            <el-form-item label="人才政策内容">
                <div id="content"></div>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="onSubmit">提交</el-button>
            </el-form-item>
        </el-form>
    </div>
</template>

<script>
import E from "wangeditor";
import requet from "@/api/axios.js";
export default {
    data() {
        return {
            form: {
                title: "",
                content: "",
            },
            editor: null,
        };
    },
    // 注册组件
    components: {},
    created() {},
    mounted() {
        const editor = new E("#content");
        editor.create();
        // 配置 onchange 回调函数，将数据同步到 vue 中
        editor.config.onchange = (newHtml) => {
            this.form.content = newHtml;
        };
        this.editor = editor;
    },
    /**
     * 里面的方法只有被调用才会执行
     */
    methods: {
        onSubmit() {
            let data = {
                TalentPolicyInfoJson: {
                    title: this.form.title,
                    content: this.form.content,
                },
            };
            if (this.form.title == "" || this.form.content == "") {
                this.$message({
                    type: "error",
                    message: "数据不能为空",
                });
            } else {
                requet.post("/hkrc/app/insertTalentPolicySelective",data).then((res) => {
                    console.log(res);
                     if(res.success){
                        this.$message({
                            type:"success",
                            message:res.msg
                        })
                    }else{
                        this.$message({
                            type:"error",
                            message:res.msg
                        })
                    }
                });
            }
        },
    },
};
</script>

<style scoped>
.el-form {
    margin-top: 50px;
}
</style>

 
 

 